/**
 * ****************************** ICE *******************************
 * ========================================================================
 * Project:  basicsipcall
 * Package: org.ice4apps.talk.callManager 
 * File:  MessageToFeatureMapping.java
 * Author: biju
 * Date: Feb 11, 2010
 * Description: This gets a bit complicated here. But letz do this so that 
 * processing of the message will be fast. 
 * We need to route a message to Feature based on the following parameters.
 *     1. Type Of the Session
 *     2. State Of the Session
 *     3. Message Type
 * We have an array of array of array build on for the first call and then 
 * Subsequent calls will get the feature list in one dip. 
 * Singleton object of each feature will register with this class
 * ========================================================================
 */
package org.ice4apps.talk.callManager;

import java.util.*;

import org.ice4apps.util.IceLog;
//import org.ice4apps.talk.entity.MessageDestinationType;
import org.ice4apps.talk.entity.MessageType;

/**
 * @author biju
 * 
 */
public class FeatureMapping
{
  public FeatureMapping() {
	  buildStructure();
  }

  public Vector<IceTalkFeature> getFeatureArray(int sessionState, int messageType){
//	  Vector <Vector> typeArray = stateMachineArray.get(sessionType);
	  Vector <Vector> stateArray = sessionTypeArray.get(sessionState);
	  Vector<IceTalkFeature> messageArray = stateArray.get(messageType);
	  
	  return (messageArray);
  }
  
  private void buildStructure(){

IceLog.info(this.getClass(), "BIJU Building State Machine");
//	  for (int i=0; i<MessageDestinationType.FINAL.ordinal();i++){
//		  Vector<Vector> endpointTypeArray = new Vector<Vector>();
//		  // Fill the State Machine Arrays with Destination Type
//		  stateMachineArray.add(i, endpointTypeArray);
//IceLog.info(this.getClass(), "BIJU Building State Machine i = " + i);
		  
		  for (int j=0; j<UserSession.UserSessionState.FINAL.ordinal();j++){
			  // Fill the Destination Type Arrays with UserSession State
			  Vector<Vector> stateArray = new Vector<Vector>();
//			  Vector <Vector> tempEndpointTypeArray = stateMachineArray.get(i);
			  sessionTypeArray.add(j,stateArray);
IceLog.info(this.getClass(), "BIJU Building State Machine j = " + j);
			  for (int k=0; k<MessageType.FINAL.ordinal();k++){
				  // Fill the UserSession State Arrays with Endpoint type
				  Vector<IceTalkFeature> messageTypeArray = new Vector<IceTalkFeature>();  
				  Vector <Vector> tempStateArray = sessionTypeArray.get(j);
				  tempStateArray.add(k,messageTypeArray);
IceLog.info(this.getClass(), "BIJU Building State Machine k = " + k);
			  }
		  }
	  }
//  }

  // The main State Machine Array
  private Vector<Vector> sessionTypeArray = new Vector<Vector>();
}